import Cocoa


func helloasync1() async -> Int {
    await withCheckedContinuation { checkedContinuation in
        DispatchQueue.global().async {
            checkedContinuation.resume(returning: 1)
        }
    }
}

func helloasync2() async -> Int {
    await withCheckedContinuation { checkedContinuation in
        DispatchQueue.global().async {
            checkedContinuation.resume(returning: 2)
        }
    }
}

let task1 = Task {
    await helloasync1()
}

//let tasks = withTaskGroup(of: <#T##Sendable.Type#>, body: <#T##(inout TaskGroup<Sendable>) async -> GroupResult#>)

let task2 = Task {
    await helloasync2()
}

//let tValue = await task.value
//print(tValue)
//Thread.sleep(forTimeInterval: 1)
//print(await task.value)

let value1 = await task1.value
let value2 = await task2.value

print(value1)
print(value2)

Thread.sleep(forTimeInterval: 1)

print("end")
